package Set01;

import java.util.Scanner;

public class tset {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i = sc.nextInt();

		int[] id = new int[i];
		int[] num = new int[i];
		String[] sum = new String[i];

		for (int j = 0; j < id.length; j++) {
			// Scanner sc1 = new Scanner(System.in);
			int b = sc.nextInt();
			int b2 = sc.nextInt();
			id[j] = b;
			num[j] = b2;
			sum[j] = id[j] + " " + num[j];

		}

		for (int j = 0; j < id.length; j++) {
			for (int j2 = j + 1; j2 < j-1; j2++) {
				if (num[j] > num[j2]) {
					String s = sum[j];
					sum[j] = sum[j2];
					sum[j2] = s;
				}
			}

			System.out.println(sum[j]);
		}

	}
}
